package com.kmproject.haifu.mvp.model;

import android.app.Application;

import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import com.jess.arms.di.scope.FragmentScope;

import javax.inject.Inject;

import com.kmproject.haifu.mvp.contract.MyCollectHouseRentContract;
import com.kmproject.haifu.mvp.model.api.service.UserService;
import com.kmproject.haifu.mvp.model.entity.ResultBean;
import com.kmproject.haifu.mvp.model.entity.beans.HouseRentListShowBean;
import com.kmproject.haifu.mvp.model.entity.beans.HouseRentListShowInfoBean;
import com.kmproject.haifu.mvp.model.entity.beans.RentHouseViewHistoryBean;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.RequestBody;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 07/11/2019 17:45
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
@FragmentScope
public class MyCollectHouseRentModel extends BaseModel implements MyCollectHouseRentContract.Model {
    @Inject
    Gson mGson;
    @Inject
    Application mApplication;

    @Inject
    public MyCollectHouseRentModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<ResultBean<List<HouseRentListShowInfoBean>>> getMeList(String url, String limit, String page,String userId) {
        return mRepositoryManager.obtainRetrofitService(UserService.class).getMeList(url,  limit,  page,userId);
    }

    @Override
    public Observable<ResultBean> delRentHouse(String url, String houseRentIds) {
        return mRepositoryManager.obtainRetrofitService(UserService.class).delRentHouse(url,houseRentIds);
    }

    @Override
    public Observable<ResultBean<List<HouseRentListShowInfoBean>>> queryCurrentUserRentHouseList(Map<String,Object> maps) {
        return  mRepositoryManager.obtainRetrofitService(UserService.class).queryCurrentUserRentHouseList(creatRequestBody(maps,mGson));
    }

    @Override
    public Observable<ResultBean> removeCurrentUserRentHouseList(Map<String, Object> maps) {
        return  mRepositoryManager.obtainRetrofitService(UserService.class).removeCurrentUserRentHouseList(creatRequestBody(maps,mGson));
    }

    @Override
    public Observable<ResultBean<List<RentHouseViewHistoryBean>>> viewRecord(String limit, String page) {
        return mRepositoryManager.obtainRetrofitService(UserService.class).viewRecord(limit,page);
    }



    @Override
    public Observable<ResultBean<List<HouseRentListShowInfoBean>>> listHouseRentCurrentUser(Map<String, Object> maps) {
        return mRepositoryManager.obtainRetrofitService(UserService.class).listHouseRentCurrentUser(creatRequestBody(maps,mGson));
    }
}